<?php
namespace Kuoqi;
class Token{
	
	//创建token，返回md5字段
	static public function create($data){
		$stream = serialize($data);
		$stream = Openssl::encode($stream);
		$tkname = md5($stream);
		\Kuoqi\Cache::setCache($tkname,$stream,86400 * 1000,'/Token',true);
		return $tkname;
	}
	
	//根据token读取并获得信息
	static public function read($tkname){
		$stream = \Kuoqi\Cache::getCache($tkname,'/Token',true);
		$stream = Openssl::decode($stream);
		return unserialize($stream);
	}
	//token机制的摧毁
	static public function destroy($tkname){
		return \Kuoqi\Cache::delCache($tkname,'/Token',true);	
	}
}
